package io.github.uicdb.badskill.api;

import net.minecraft.nbt.Tag;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.player.Player;

import java.util.HashMap;
import java.util.function.Function;

public class CostumerConsumerManager  {
    private static final HashMap<ResourceLocation, Function<Player, CostumerConsumer>> factories=new HashMap<>();
    private static final Function<Player, CostumerConsumer> EMPTY= player -> CostumerConsumer.EMPTY;

    /**
     * Use {@link RegisterConsumerEvent} instead
     */
    protected static void register(ResourceLocation key, Function<Player, CostumerConsumer> function){
        factories.put(key, function);
    }
    public static int size(){
        return factories.size();
    }

    public static CostumerConsumer get(ResourceLocation key, Player player){
        return factories.getOrDefault(key,EMPTY).apply(player);
    }
}
